// 导入axios实例
import request from "@/utils/request";

// 获取文章详情
export const getArticleInfoApi = (article_id) => {
  return request({
    url: "/v1_0/articles/" + article_id,
  });
};
// getArticleInfoApi(20)

// 关注用户
export const addUserFollowApi = (data) => {
  return request({
    url: "/v1_0/user/followings",
    method: "post",
    // data: data,
    data,
  });
};
// 取消关注用户
export const delUserFollowApi = (id) => {
  return request({
    url: "/v1_0/user/followings/" + id,
    method: "delete",
  });
};

// 收藏文章
export const addArticleCollectApi = (data) => {
  return request({
    url: "/v1_0/article/collections",
    method: "post",
    // data: data,
    data,
  });
};
// 取消收藏文章
export const delArticleCollectApi = (id) => {
  return request({
    url: "/v1_0/article/collections/" + id,
    method: "delete",
  });
};

// 点赞文章
export const addArticleZanApi = (data) => {
  return request({
    url: "/v1_0/article/likings",
    method: "post",
    // data: data,
    data,
  });
};
// 取消点赞
export const delArticleZanApi = (id) => {
  return request({
    url: "/v1_0/article/likings/" + id,
    method: "delete",
  });
};

// 获取文章评论或评论的回复
export const getCommentListAPi = (params) => {
  return request({
    url: "/v1_0/comments",
    method: "GET",
    // params: {
    //   type: "a/c", // 获取文章评论传入  a    获取评论回复 传入 c
    //   source: "文章ID或评论ID", // 获取文章评论传入  文章id   获取评论回复 传入 评论ID
    //   offset: "null/评论ID",
    //   limit: "每页数量",
    // },
    params: params,
  });
};
// 对评论点赞
export const addCommentZanApi = (id) => {
  return request({
    url: "/v1_0/comment/likings",
    method: "post",
    data: {
      target: id,
    },
  });
};
// 取消评论点赞
export const delCommentZanApi = (id) => {
  return request({
    url: "/v1_0/comment/likings/" + id,
    method: "delete",
  });
};

// 发布文章评论或 发布评论回复
export const addCommentInfoApi = (data) => {
  return request({
    url: "/v1_0/comments",
    method: "post",
    // data: {
    //   //                     发布文章评论    发布评论回复
    //   target: "目标ID", //      文章的ID      评论的ID
    //   content: "内容",
    //   art_id: "文章ID", //        null       文章ID
    // },
    data,
  });
};
